<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="util" uri="/WEB-INF/kdd-util.tld" %>
<%@taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<script type="text/javascript" src="<c:url value='/resources/js/jit.js' />"></script>
<style>
    .tip {
        width: 150px;
        background: #fff;
        text-align: center;
        color: #666;
        border: 1px solid #666;
        padding: 3px;
    }
</style>
<div class="well">
    <b><spring:message code="msg.outputdata" />:</b><br /><br />
    <c:choose>
        <c:when test="${empty outputData}">
            <spring:message code="msg.nooutputdata" />
        </c:when>
        <c:otherwise>
            <input type="text" id="outputdatafilter" placeholder="Filter" />
            <ul id="outputdatalist">
                <c:forEach items="${outputData}" var="sp">
                    <c:choose>
                        <c:when test="${not empty sp.url}">
                            <li><span><a href="<c:url value='${sp.url}'/>">${sp.title}</a></span></li>
                        </c:when>
                        <c:otherwise>
                            <c:choose>
                                <c:when test="${sp.title == 'jitjson'}">
                                    <script type="text/javascript">
                                        $(function() {
                                            var json = ${sp.val};
                                            var pie = new $jit.PieChart({  
                                                injectInto: 'infovis',
                                                animate: true,
                                                offset: 0,
                                                sliceOffset: 1,
                                                labelOffset: -20,
                                                type: 'stacked',
                                                showLabels: true,
                                                resizeLabels: 15,
                                                updateHeights: true,
                                                hoveredColor: '#eee',
                                                height: '300',
                                                Label: {
                                                    type: 'HTML', //Native or HTML
                                                    size: 20,
                                                    family: 'Arial',
                                                    color: '#333'
                                                },
                                                Tips: {
                                                    enable: false
                                                }
                                            }); 
                                            pie.loadJSON(json);
                                        });
                                    </script>
                                </c:when>
                                <c:otherwise>
                                    <li class="padding"><span><strong>${sp.title}:</strong><br />${util:nl2br(sp.val)}</span></li>
                                </c:otherwise>
                            </c:choose>
                        </c:otherwise>
                    </c:choose>
                </c:forEach>
            </ul>
        </c:otherwise>
    </c:choose>
</div>
<div class="well">
    <div id="infovis"></div>    
</div>
<div class="well">
    <h5><spring:message code="msg.parameters" />:</h5><br />
    <util:dynamicconfigoutput value="${result.config}" />
</div>